<?php
/**
 + Created by:	Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webitsolution.com , info@webitsolution.com
				www.wrecruit.com, developer@wrecruit.com
 * Created on:	Dec 30, 2012
 ^
 + Project: 		WRecruit 
 * File Name:	module/jsjobcategories.php
 ^ 
 * Description: Module for WRecruit
 ^ 
 * History:		1.0.0 - Dec 30, 2012
 ^ 
 */

defined('_JEXEC') or die('Restricted access');

/** scs */
if($params->get('Itemid')) $itemid = $params->get('Itemid');			
else $itemid =  JRequest::getVar('Itemid');
$componentAdminPath = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_wrecruit';
$componentPath =  'components' . DS . 'com_wrecruit';
require_once $componentPath . DS . 'models' . DS . 'mpwrecruit.php';
$config = array( 'table_path' => $componentAdminPath . DS . 'tables');
$model = new WRecruitModelMpWRecruit($config);
$result = $model->getJobCategories('');
$categories = $result[0];
?>
<div class="head-title">
	<h2>Jobs by Industry</h2>
</div>
<?php
if ($categories) {
	if(count($categories)) {
		//display only 9 items in the list
		for($i = 0; $i < 30 && count($categories) > $i; $i++){
			if ($categories[$i]->catinjobs > 0){
				$nineCategories[] = $categories[$i];
			}
		}
		$numitems = count($nineCategories);
		$firstrow = $secondrow = $thirdrow = (int)($numitems / 3);
		if($numitems % 3 > 0){
			$firstrow += 1;
		}
		if($numitems % 3 == 2){
			$secondrow += 1;
		}
		$i = 0;
		
		foreach($nineCategories as $category){
			
			if($i == 0){
				echo '<ul class="left">';
			}
			elseif($i == $firstrow){
				echo '</ul>';
				echo '<ul class="middle">';
			}
			elseif($i == ($firstrow + $secondrow)){
				echo '</ul>';
				echo '<ul class="right">';
			}
			$class = '';
			if(($i == $firstrow - 1) || ($i == ($firstrow + $secondrow) - 1) || ($i == ($numitems) - 1)){
				$class = ' class="last"';
			}
			$lnks = 'index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=list_jobs&jobcat='. $category->id .'&Itemid='.$itemid; 
			$lnks = JRoute::_($lnks);
			echo '<li' . $class . '><a href="' . $lnks . '">' /*. ($i + 1) . '. '*/ . $category->cat_title . '</a><span>(' . $category->catinjobs . ')</span></li>';
			if($i == $numitems - 1){
				echo '</ul>';
			}
			$i += 1;
		}
	}
}
?>

